package com.example.jikeyoujikeyou.office_sz.view.activity.register.subActivity;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import com.example.jikeyoujikeyou.office_sz.R;
import com.example.jikeyoujikeyou.office_sz.view.TitleBar;
import com.example.jikeyoujikeyou.office_sz.view.activity.register.ChoiceDepartmentAdapter;
import com.example.jikeyoujikeyou.office_sz.view.activity.register.RegisterActivity;
import com.example.jikeyoujikeyou.office_sz.view.base.BaseActivity;

public class Activity_Choice_Department extends BaseActivity {

    private String departmentName;
    private ListView department_list;
    private ChoiceDepartmentAdapter adapter;
    private View previous_view = null;
    private TitleBar titleBar;

    private static final int SUCCESS = 300;
    private static final int FAILURE = 0;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_choice_department);
        init();
    }

    private void init() {

        setTitle("选择部门");
        titleBar = getTitleBar();
        titleBar.getIv_return().setVisibility(View.GONE);
        titleBar.getTv_cancel().setVisibility(View.VISIBLE);

        titleBar.getTv_cancel().setText("取消");

        titleBar.getTv_cancel().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                setResult(FAILURE, new Intent());
                finish();
            }
        });

        department_list = (ListView) findViewById(R.id.department_list);

        adapter = new ChoiceDepartmentAdapter(getBaseContext());
        adapter.setDepartmentList(RegisterActivity.company.getDepartments());

        department_list.setAdapter(adapter);

    }

    private void setTitle(String title){
        getTitleBar().getTv_title().setText(title);
    }

}
